package com.itheima.test04;

public class Test {
    public static void main(String[] args) {
        Wolf w= new Wolf();
        System.out.println(w.pi);
        w.eat();
        w.jiao();
        Sheep s= new Wolf();//多态    子类对象 地址值 给 父类的变量  子类对象指向父类的引用
        Wolf w3=(Wolf) s;
        w3.jiao();
        s.eat();
        System.out.println(s.pi);

        Sheep sheep= new Sheep();
        Wolf w2=(Wolf) sheep;
        w2.jiao();
        fangyang(sheep);
        fangyang(s);
        langJiao(w);

    }

    public static void fangyang(Sheep sheep){
        sheep.eat();
    }

    public static void langJiao(Wolf sheep){
        sheep.jiao();
    }
}
/**
 * 披着羊皮的狼
 */
class Wolf extends Sheep{
     String pi="狼毫";
    public void eat(){
        System.out.println("狼吃羊");
    }
    public void jiao(){
        System.out.println("嗷呜!!");
    }


}
class Sheep{
     String pi="羊毛";

    public void eat(){
        System.out.println("羊吃草");
    }


}

